<?php


namespace Cblood\Sword\Operation;

/**
 * 组织 sql 语句之 where
 * @package Cblood\Sword\Operation;
 */
class OrganizeSelect extends OrganizeSqlBasic
{
    /**
     * 生成查询语句
     * @return string
     */
    public function create()
    {
        $sql = 'SELECT ' . $this->field . ' FROM ' . $this->getTable();
        if (!empty($this->where)) {
            $sql .= ' WHERE ' . $this->createWhereConditions();
        }

        if (!empty($this->orderBy)) {
            $sql = $sql . $this->orderBy;
        }

        if (!empty($this->limit)) {
            $sql = $sql . $this->limit;
        }
        return $sql;
    }

}